﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using order.Models;
using order.Service;

namespace order.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SysUserController : ControllerBase
    {
        private readonly ISysUserService _sysUserService;

        public SysUserController(ISysUserService sysUserService) {
            _sysUserService= sysUserService;
        }
        [HttpGet("GetSysUserById")]
        public ActionResult GetSysUserById(int id)
        {
            return Ok(_sysUserService.GetSysUser(id));
        }
        
        //用户添加
        [HttpPost("AddSysUser")]
        public ActionResult AddSysUser(SysUser sysUser)
        {
            _sysUserService.AddSysUser(sysUser);
            return Ok();
        }


        [HttpGet("DeleteSysUser")]
        public ActionResult DeleteSysUser(int id)
        {
            _sysUserService.DeleteSysUser(id);  
            return Ok();
        }

        [HttpGet]

        public ActionResult GetAllSysUser() {  return Ok(_sysUserService.GetSysUsers()); }

    }
    

    
}
